package com.wangcanxuan.www.dao.mapper;

import com.wangcanxuan.www.annotation.orm.ReturnType;
import com.wangcanxuan.www.annotation.orm.Select;
import com.wangcanxuan.www.entity.po.User;
import com.wangcanxuan.www.proxy.constants.ReturnDataType;

import java.lang.reflect.Field;
import java.util.List;

/**
 * 用户类Mapper
 *
 * @author HHLJ
 * @date 2022/04/01
 */
public interface UserMapper extends BaseMapper<User>{
    /**
     * 选择用户通过部落id列表
     *
     * @param tribeId   部落id
     * @param pageCount 页面数
     * @return {@link List}<{@link User}>
     */
    @Select(sql = "SELECT * FROM `user` WHERE tribe_id = ? ORDER BY role_id DESC LIMIT ?,10")
    @ReturnType(returnType = ReturnDataType.LIST)
    List<User> selectUserListByTribeId(String tribeId,int pageCount);

    /**
     * 选择性别和部落id和用户列表的搜索的名字
     * 选择用户列表由性别部落id
     *
     * @param tribeId    部落id
     * @param gender     性别
     * @param pageCount  页面数
     * @param searchName 搜索的名字
     * @return {@link List}<{@link User}>
     */
    @Select(sql = "SELECT * FROM `user` WHERE tribe_id = ? AND gender = ? AND nick_name like ? ORDER BY role_id DESC LIMIT ?,10")
    @ReturnType(returnType = ReturnDataType.LIST)
    List<User> selectUserListByGenderAndTribeIdAndSearchName(String tribeId,String gender,String searchName,int pageCount);

    /**
     * 选择用户通过部落id列表和搜索的名字
     * 选择性别和部落id和用户列表的搜索的名字
     * 选择用户列表由性别部落id
     *
     * @param tribeId    部落id
     * @param pageCount  页面数
     * @param searchName 搜索的名字
     * @return {@link List}<{@link User}>
     */
    @Select(sql = "SELECT * FROM `user` WHERE tribe_id = ? AND nick_name like ? ORDER BY role_id DESC LIMIT ?,10")
    @ReturnType(returnType = ReturnDataType.LIST)
    List<User> selectUserListByTribeIdAndSearchName(String tribeId,String searchName,int pageCount);

    /**
     * 选择用户列表由性别部落id
     *
     * @param tribeId   部落id
     * @param gender    性别
     * @param pageCount 页面数
     * @return {@link List}<{@link User}>
     */
    @Select(sql = "SELECT * FROM `user` WHERE tribe_id = ? AND gender = ? ORDER BY role_id DESC LIMIT ?,10")
    @ReturnType(returnType = ReturnDataType.LIST)
    List<User> selectUserListByGenderByTribeId(String tribeId,String gender,int pageCount);

    /**
     * 通过部落id获得人数
     *
     * @param tribeId 部落id
     * @return {@link Integer}
     */
    @Select(sql = "SELECT count(*) FROM user WHERE tribe_id = ?")
    @ReturnType(returnType = ReturnDataType.FIELD)
    Long selectNumbersForTribe(String tribeId);
}
